var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (e, i) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, e) {
              t.__proto__ = e;
            }) ||
          function (t, e) {
            for (var i in e)
              Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
          })(e, i);
      };
      return function (e, i) {
        function n() {
          this.constructor = e;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        t(e, i),
          (e.prototype =
            null === i
              ? Object.create(i)
              : ((n.prototype = i.prototype), new n()));
      };
    })(),
  GuessSizeFitView = (function (t) {
    function e() {
      var e = t.call(this) || this;
      return (
        (e.onLoadSliverCouponFn = {
          caller: e,
          code: 1063,
          method: function (t) {
            0 == t.code &&
              ((e.sliver_coupon = parseInt(t.data)),
              0 == e.sliver_coupon
                ? (e.btn_youhuiquan.mouseEnabled = !1)
                : (e.btn_youhuiquan.mouseEnabled = !0),
              (e.lbl_sliver_num.text = t.data));
          },
        }),
        (UIConfig.closeDialogOnSide = !1),
        e.btn_caijinCoin.on(Laya.Event.CLICK, e, e.onGuessButtonDidClickFn),
        e.btn_caiyinCoin.on(Laya.Event.CLICK, e, e.onGuessButtonDidClickFn),
        e.btn_guessOne.on(Laya.Event.CLICK, e, e.onGuessSizeDescrActionFn),
        e.btn_guessTwo.on(Laya.Event.CLICK, e, e.onGuessSizeDescrActionFn),
        e.btn_guessThree.on(Laya.Event.CLICK, e, e.onGuessSizeDescrActionFn),
        e.btn_guessFour.on(Laya.Event.CLICK, e, e.onGuessSizeDescrActionFn),
        WebSocketService.addListener(e.onLoadSliverCouponFn),
        e.btn_youhuiquan.on(Laya.Event.CLICK, e, e.onGuessSizeDescrActionFn),
        e
      );
    }
    return (
      __extends(e, t),
      (e.open = function (t, i, n) {
        null == this.fitView &&
          ((this.fitView = new e()), (this.fitView.zOrder = 1e3)),
          this.fitView.popup(!0),
          (this.fitView.totalBetNum = 0),
          (this.fitView.guessSizeFittype = "caicai"),
          (this.fitView.gleft_type = i),
          (this.fitView.gright_type = n),
          (this.fitView.lbl_guessTitle.text = t),
          (this.fitView.sliver_coupon = 0),
          (this.fitView.lbl_sliver_num.text = "0"),
          WebSocketService.send({ c: 1063, d: { goodsId: 123 } });
      }),
      (e.openSanGuo = function (t, i, n) {
        null == this.fitView &&
          ((this.fitView = new e()), (this.fitView.zOrder = 1e3)),
          this.fitView.popup(!0),
          (this.fitView.totalBetNum = 0),
          (this.fitView.guessSizeFittype = "sanguo"),
          "魏国" == t
            ? (this.fitView.guessSide = "1")
            : "蜀国" == t
            ? (this.fitView.guessSide = "2")
            : "吴国" == t && (this.fitView.guessSide = "3"),
          (this.fitView.gleft_type = i),
          (this.fitView.gright_type = n),
          (this.fitView.lbl_guessTitle.text = t),
          this.fitView.btn_caijinCoin.on(
            Laya.Event.CLICK,
            this.fitView,
            this.fitView.onGuessButtonDidClickFn
          ),
          this.fitView.btn_caiyinCoin.on(
            Laya.Event.CLICK,
            this.fitView,
            this.fitView.onGuessButtonDidClickFn
          ),
          this.fitView.btn_guessOne.on(
            Laya.Event.CLICK,
            this.fitView,
            this.fitView.onGuessSizeDescrActionFn
          ),
          this.fitView.btn_guessTwo.on(
            Laya.Event.CLICK,
            this.fitView,
            this.fitView.onGuessSizeDescrActionFn
          ),
          this.fitView.btn_guessThree.on(
            Laya.Event.CLICK,
            this.fitView,
            this.fitView.onGuessSizeDescrActionFn
          ),
          this.fitView.btn_guessFour.on(
            Laya.Event.CLICK,
            this.fitView,
            this.fitView.onGuessSizeDescrActionFn
          ),
          this.fitView.btn_youhuiquan.on(
            Laya.Event.CLICK,
            this.fitView,
            this.fitView.onGuessSizeDescrActionFn
          ),
          WebSocketService.send({ c: 210, d: { no: 3 } });
      }),
      (e.prototype.onGuessSizeDescrActionFn = function (t) {
        var e = t.target.name;
        if ("item0" == e) this.totalBetNum += 100;
        else if ("item1" == e) this.totalBetNum += 1e3;
        else if ("item2" == e) this.totalBetNum += 1e4;
        else if ("item3" == e) this.totalBetNum += 1e5;
        else if ("daijinquan" == e)
          return (
            "sanguo" == this.guessSizeFittype
              ? WebSocketService.send({
                  c: 4437,
                  d: { side: this.guessSide, type: 3, bet: 0 },
                })
              : WebSocketService.send({
                  c: 1336,
                  d: { action: 1, type: this.gright_type, bet: 1 },
                }),
            void this.close()
          );
        this.text_customCoin.text = this.totalBetNum + "";
      }),
      (e.prototype.onGuessButtonDidClickFn = function (t) {
        t.target;
        var e = "";
        "caijinbutton" == t.target.name
          ? ((this.bettype = "1"), (e = this.gleft_type))
          : ((this.bettype = "2"), (e = this.gright_type));
        var i = parseInt(this.text_customCoin.text);
        if (i <= 0 || isNaN(i))
          return this.close(), void ToastView.toastView("请输入下注数量");
        i > 0 &&
          ("sanguo" == this.guessSizeFittype
            ? WebSocketService.send({
                c: 4437,
                d: { side: this.guessSide, type: e, bet: i },
              })
            : WebSocketService.send({
                c: 1336,
                d: { action: 0, type: e, bet: i },
              }),
          WebSocketService.send({ c: 210, d: { no: 3 } })),
          (this.text_customCoin.text = ""),
          this.close();
      }),
      (e.close = function () {
        this.fitView &&
          ((this.fitView.text_customCoin.text = ""), this.fitView.close());
      }),
      e
    );
  })(ui.SquareController.GuessSizeFitViewUI);
